/**
 *@program: getx_simple_code
 *@description:
 *@author: Ming
 *@create: 2024-01-14 19:59
 *@version v1.0
 */
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getx_simple_code/common/widgets/cusHeader.dart';
import 'package:getx_simple_code/pages/diovc/pojo/dishesEntity.dart';
import 'package:getx_simple_code/pages/refresh/logic.dart';
import 'package:getx_simple_code/common/widgets/cusFooter.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

class comListWidget extends GetView<RefreshLogic> {

  @override
  Widget build(BuildContext context) {
    return GetBuilder<RefreshLogic>(
      builder: (controller) {
        return SmartRefresher(
          controller: controller.refreshController,
          enablePullUp: true,
          header: cusHeader(),
          footer: cusFooter(),
          onRefresh: controller.onRefresh,
          onLoading: controller.onLoading,
          child: _buildListView(controller.state.dataList),
        );
      },
    );
  }
  _buildListView(List<Records>? items) {
    return ListView.separated(
      itemCount: items!.length,
      itemBuilder: (context, index) {
        final Records item = items[index];
        return ListTile(
            title: Text(
              '菜品名称:${item.name}',
              style: TextStyle(fontSize: 20, color: Colors.black),
            ),
            trailing: Text(
              "分类:${item.categoryName}",
              style: TextStyle(fontSize: 18, color: Colors.orange),
            ));
      },
      separatorBuilder: (BuildContext context, int index) {
        return Divider();
      },
    );
  }
}